package my.util;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import org.apache.log4j.Logger;

/**
 * 读取properties配置文件
 * 
 * @author corey
 * 
 */
public class PropertiesUtil {

	static Logger log = Logger.getLogger(PropertiesUtil.class.getName());

	public static Properties getProperties(String filePath) {
		Properties prop = null;
		InputStream is = null;
		prop = new Properties();
		try {
			is = new FileInputStream(new File(filePath));
		} catch (FileNotFoundException e1) {
			log.error("没有找见该路径的配置文件：" + filePath);
			return null;
		}
		try {
			prop.load(is);
		} catch (IOException e) {
			log.error("读取配置文件IO错误：" + e.toString());
			return null;
		}
		try {
			is.close();
		} catch (IOException e) {
			log.error("关闭读取配置文件IO操作错误：" + e.toString());
			return null;
		}
		return prop;
	}
}
